#@head() 
#@header()
<title>营销管理</title>
#@aside("marketing")
<div class="content-wrapper">
	<section class="content">
		<div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
              <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true">新建体验金</a></li>
              <!--<li class="active"><a href="#tab_2" data-toggle="tab" aria-expanded="false">还款管理</a></li>-->
            </ul>
            <div class="tab-content">
              <div class="tab-pane active" id="tab_1">
				<div class="box-body">
					<table id="example1" style="width:800px;" class="table table-striped">
						<tbody>
							<tr>
								<th align="right" style="width:100px;">名称：</th>
								<td><input id="name" type="text" class="form-control" placeholder="体验金名称"></td>
							</tr>
							<tr>
								<th align="right" style="width:100px;">状态</th>
								<td>
									<select id="status" class="form-control">
										<option value="disable">停用</option>
										<option value="enable">启用</option>
										<option value="stop">手动结束</option>
									 </select>
								</td>
							</tr>
							
							<tr>
								<th align="right" style="width:100px;">体验金总额：</th>
								<td><input id="num" type="text" class="form-control" placeholder="体验金总额"></td>
							</tr>
							<tr>
								<th align="right" style="width:100px;">投资满多少可以用：</th>
								<td><input id="limitAmount" type="text" class="form-control" placeholder="投资满多少可以用"></td>
							</tr>
							<tr>
								<th align="right" style="width:100px;">体验金类型：</th>
								<td>
									<select id="type" class="form-control">
										<option value="tyj">体验金</option>
									 </select>
								</td>
							</tr>
							<tr>
								<th align="right" style="width:100px;">可否重复领取</th>
								<td>
									<select id="isRepeat" class="form-control">
										<option value="1">是</option>
										<option value="0">否</option>
									 </select>
								</td>
							</tr>
							<tr>
								<th align="right" style="width:200px;">可用标的</th>
								<td>
									<select id="allowBid" class="form-control select2 select2-hidden-accessible" multiple="" data-placeholder="请选择适用的标的类型..." style="width: 100%;" tabindex="-1" aria-hidden="true">
									  <option value="first">新手标</option>
									  <option value="30day">1月标</option>
									  <option value="90day">3月标</option>
									  <option value="180day">6月标</option>
									  <option value="360day">12月标</option>
									  <option value="experi">体验标</option>
									</select>
								</td>
							</tr>
							<tr>
								<th align="right" style="width:100px;">活动链接：</th>
								<td>
									<input id="link" type="text" class="form-control" placeholder="活动链接">
								</td>
							</tr>
							<tr>
								<th align="right" style="width:100px;">活动时间：</th>
								<td>
									<input id="startTime" type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width:180px;float:left" class="form-control" placeholder=""> 
									<span style="float:left;margin:5px 5px 0 5px;" > 至 </span>
									<input id="endTime" type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width:180px;float:left" class="form-control" placeholder="">
								</td>
							</tr>
							<tr>
								<th align="right" style="width:100px;">体验金有效期：</th>
								<td>
									<input id="validStartTime" type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width:180px;float:left" class="form-control" placeholder=""> 
									<span style="float:left;margin:5px 5px 0 5px;" > 至 </span>
									<input id="validEndTime" type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width:180px;float:left" class="form-control" placeholder="">
								</td>
							</tr>
							<tr>
								<th align="right" style="width:100px;">发放规则：</th>
								<td>
									<select id="rule" class="form-control">
										<option value="reg">注册</option>
										<option value="real">实名</option>
										<option value="deposit">充值</option>
										<option value="invest">单笔满投</option>
									</select>
									<div id="ruleAmount1" hidden>
										<input id="amount" style="margin-top:10px;" type="text" class="form-control"  placeholder="金额">
									</div>
									<div id="ruleAmount2" hidden>
										<div style="clear:both">
											<span style="float:left;margin:15px 10px 0 0;">满</span>
											<input style="margin-top:10px;width:200px;float:left" type="text" class="form-control amount" placeholder="金额">
											<span style="float:left;margin:15px 10px 0 10px;">送</span>
											<input style="margin-top:10px;width:200px;float:left" type="text" class="form-control"  placeholder="金额">
										</div>
										<div>
											<button id="add" type="button" class="btn bg-maroon margin">新增</button>
										</div>
									</div>
				
								</td>
							</tr>
							</tr>
						</tbody>
					</table>
				</div>
				<div class="box-footer">
					<button type="submit" id="submit" style="margin-left:10px;" class="btn btn-info ">提交</button>
					<button onclick="window.location.href='/admin/page/marketing-redpacket'" type="submit" style="margin-left:10px;" class="btn btn-default">取消</button>
				  </div>
              </div>
            </div>
            <!-- /.tab-content -->
          </div>
		  
	</section>
</div>
#@footer()
<script>
$(document).ready(function(){
	$("#allowBid").select2();
	if($("#rule").val()=="reg"||$("#rule").val()=="real"){
		$("#ruleAmount1").show();
		$("#ruleAmount2").hide();
	}else if($("#rule").val()=="deposit"||$("#rule").val()=="invest"){
		$("#ruleAmount2").show();
		$("#ruleAmount1").hide();
	}
	$("#rule").change(function(){ 
		if($("#rule").val()=="reg"||$("#rule").val()=="real"){
			$("#ruleAmount1").show();
			$("#ruleAmount2").hide();
		}else if($("#rule").val()=="deposit"||$("#rule").val()=="invest"){
			$("#ruleAmount2").show();
			$("#ruleAmount1").hide();
		}
	});
	$("#add").click(function(){
		 $("#ruleAmount2").append("<div style='clear:both'><span style='float:left;margin:15px 10px 0 0;'>满</span><input style='margin-top:10px;width:200px;float:left' type='text' class='form-control amount' placeholder='金额'><span style='float:left;margin:15px 10px 0 10px;'>送</span><input style='margin-top:10px;width:200px;float:left' type='text' class='form-control'  placeholder='金额'></div>");
	});
	
	$("#submit").click(function() {
		layer.confirm('是否确认提交？', {btn : [ '确认', '取消' ]}, function() {
			var params = getFormVals("#tab_1");
			if($("#ruleAmount1").is(":hidden")){
				var args = new Array();
				$(".amount").each(function(i){
					var t = {target:$(this).val(),amount:$(this).next().next().val()};
					args.push(t);
				});
				params['ruleAmount'] = JSON.stringify(args);
			}else{
				params['ruleAmount'] = $("#amount").val();
			}
			ajax("#(path)/coupon/edit?token=#(session.token??)&",params,function(data){
				if(data.code=='success'){
					layer.msg(data.msg, {icon:1},function(){
						location.href="#(path)/admin/page/marketing-redpacket"
					});
				}else if(data.code=='error'){
					layer.msg(data.msg, {icon : 2});
				}
			});
		}, function() {
			layer.msg('已取消！', {icon : 1});
		});
	});
});
</script>
</body>
</html>

